#include "PhysicSystem.h"

PhysicSystem::PhysicSystem(){};
PhysicSystem::~PhysicSystem(){};

int PhysicSystem::Initialize(){

	return 0;
};

int PhysicSystem::Update(float a_timePassed){
	//m_PhysicCollisionDetection.Update(&m_RigidBodyList);
	m_PhysicCollisionResolution.Update(&m_RigidBodyList, a_timePassed);

	return 0;
};

void PhysicSystem::Release(){
	m_RigidBodyList.Clear();
};

void PhysicSystem::Create(PhysicObject *a_PhysicObject){
	Destroy(a_PhysicObject);
	PhysicRigidBody *t_PhysicRigidBody = new PhysicRigidBody(a_PhysicObject);
	m_RigidBodyList.Insert_ToEnd(t_PhysicRigidBody);
};

void PhysicSystem::Destroy(PhysicObject *a_PhysicObject){
	int t_size = m_RigidBodyList.Get_Size();
	for(int i = 0; i < t_size; i++){
		PhysicRigidBody *t_PhysicRigidBody = m_RigidBodyList.Get_Data(i);
		if(a_PhysicObject == t_PhysicRigidBody->m_PhysicObject){
			m_RigidBodyList.Remove_FromIndex(i);
			break;
		}
	}
};
